﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Autodesk.AutoCAD.Interop;
namespace Congducsan
{
    class ClsTDau
    {
        public AcadApplication mvarobjApp;
        public object ArrDimT;
        public object ArrDimD;
        public object ArrDimV;
        public Boolean BaccapGc;
        public Double SLopdem;
        public Double Docdoc;
        public String TlCd;
        //Trac ngang
        public object ArrTaluyTren;
        public object ArrTaluyDuoi;
        public object ArrTaluyTren1;
        public object ArrTaluyDuoi1;
        public object ArrTaluyTren2;
        public object ArrTaluyDuoi2;
        public Double ToadoMaxTd;
        //Duong tim
        public long idDuongtim;
        public object dataDuongtim;
        private Boolean TdCaohonVai;
        public Boolean GcNamsauTd;
        //Mat bang
        public long idTaluyTren;
        public long idTaluyDuoi;
        public long idTaluy;
        //Mat chieu
        public long idTaluyTrai;
        public long idTaluyPhai;
        public long idTaluyChieu;
        public Double RongtaluyB2;
        private object H_Duongdo;
        private Double X_Tam;
        private Double X_Bien;
        private Double mvarCao;
        private Double mvarDoc;
        private Double mvarMrongtuong;
        private Double mvarMrongT;
        private Double mvarMrongS;
        private Double mvarMrongB;
        private Double mvarMrongb4;
        private Double mvarDayMTr;
        private Double mvarDayMSau;
        private Double mvarRongMongD;
        public Boolean isRongMongD;
        public Double Daiong;
        private Double mvarDay;
        private Double mvarTana;
        private int mvarTraiphai;
        private Double mvarDuongkinh;
        private Double mvarDayong;
        private Double mvarCaocong;
        private Double mvarDayban;
        private Double mvarSoday;
        private Double mvarKCachDay;
        private Double mvarCaoH1Tc;
        private Double mvarDayTc;
        private Double mvarGoca1;
        private Double mvarGoca2;
        private Double mvarLopdem;
        private Double mvarTlB;
        private String mvarTl;
        private int mvarTlT;
        private Boolean mvarKtVuongGoc;
        private int mvarCongtron;
        private Boolean mvarCotai;
        private Double mvarSautaih1;
        private Double mvarCaotaiH2;
        private Double mvarDaytaiD;
        private Double mvarCaoTuongH1;
        private Double mvarSaumongH2;
        private String mvarVlTd;
        private String mvarVlTaluy;
        private Double mvarGocxien;
        private Double mvarDaytaluy;
        private Double mvarCaotaluyh1;
        private Double mvarCaotaluyh2;
        private Double mvarRongtaluyB1;
        private Double mvarRongdinhtaluy;
        private Double mvarRongVaitaluy;
        private Boolean mvarOpmaiTrai;
        private Boolean mvarOpmaiPhai;
        private Boolean mvarOpmaiFull;
        public Double DaitaluyL;
        public Double RongtaluyTc;
        public Double DaitaluyTc;
        private long Vitritim;
        public Double CdDauvao;
        public Double CdTimduong;
        private Double CdDinhTd;
        public object Tdden;
        public object Tddo;
        //Cac bien toan cuc
        private long mvarTcId_Duongdo;
        private Double mvarTcDChanT0;
        private Double mvarTcDChanP0;
        private Double mvarTcDChanT1;
        private Double mvarTcDChanP1;
        private Double mvarTcKcDinhTdP;
        private Double mvarTcKcDinhTdT;
        private Double mvarTcDaiduongTluy1;
        private Double mvarTcDaiduongTluy2;
        private Double mvarTcDaiduongTluy3;
        private Double mvarTcDaiduongTluy4;
        private Double mvarHsKc;
        private ClsCommon Com;
        const Double Pi = 3.14159265358979;
        private Double mvarCaochuG;
        private Double mvarCaochuT;

        public Double CaochuG
        {
            set { mvarCaochuG = value; }
            get { return mvarCaochuG * TlDim; }
        }
        public Double CaochuT
        {
            set { mvarCaochuT = value; }
            get { return mvarCaochuT * TlDim; }
        }
        private void Class_Terminate()
        {
            //Set Com = Nothing;
        }
        private void Class_Initialize()
        {
            //Set Com = New ClsCommon;
        }


        /// <summary>
        /// CÁC THUỘC TÍNH - PROPERTIES
        /// </summary>
        public Double HsKc
        {
            set { mvarHsKc = value; }
            get { return mvarHsKc; }
        }
        public Double Daytaluy
        {
            set { mvarDaytaluy = value; }
            get { return mvarDaytaluy; }
        }
        public Double Caotaluyh1
        {
            set { mvarCaotaluyh1 = value; }
            get { return mvarCaotaluyh1; }
        }
        public Double Caotaluyh2
        {
            set { mvarCaotaluyh2 = value; }
            get { return mvarCaotaluyh2; }
        }
        public Double RongtaluyB1
        {
            set { mvarRongtaluyB1 = value; }
            get { return mvarRongtaluyB1; }
        }
        public Double Rongdinhtaluy
        {
            set { mvarRongdinhtaluy = value; }
            get { return mvarRongdinhtaluy; }
        }
        public Double RongVaitaluy
        {
            set { mvarRongVaitaluy = value; }
            get
            {
                if (OpmaiFull)
                {
                    return mvarRongVaitaluy;
                }
                else
                {
                    return 0;
                }
            }
        }
       
        public Boolean OpmaiTrai
        {
            set { mvarOpmaiTrai = value; }
            get { return mvarOpmaiTrai; }
        }
        public Boolean OpmaiPhai
        {
            set { mvarOpmaiPhai = value; }
            get { return mvarOpmaiPhai; }
        }
        public Boolean OpmaiFull
        {
            set { mvarOpmaiFull = value; }
            get { return mvarOpmaiFull; }
        }
        public Double GocXien
        {
            set { mvarGocxien = value; }
            get { return mvarGocxien * Pi / 180; }
        }
        public Double Gocdoi
        {
            get { return 0.5 * Pi - GocXien; }
        }
        public Double TcKcDinhTdT
        {
            set { mvarTcKcDinhTdT = value; }
            get { return mvarTcKcDinhTdT; }
        }
        public Double TcDChanT0
        {
            set { mvarTcDChanT0 = value; }
            get { return mvarTcDChanT0; }
        }
        public Double TcDChanT1
        {
            set { mvarTcDChanT1 = value; }
            get { return mvarTcDChanT1; }
        }

        public Double TcDChanP0
        {
            set { mvarTcDChanP0 = value; }
            get { return mvarTcDChanP0; }
        }
        public Double TcDChanP1
        {
            set { mvarTcDChanP1 = value; }
            get { return mvarTcDChanP1; }
        }
        public Double TcKcDinhTdP
        {
            set { mvarTcKcDinhTdP = value; }
            get { return mvarTcKcDinhTdP; }
        }
        public Double TcDaiduongTluy1
        {
            set { mvarTcDaiduongTluy1 = value; }
            get { return mvarTcDaiduongTluy1; }
        }
        public Double TcDaiduongTluy2
        {
            set { mvarTcDaiduongTluy2 = value; }
            get { return mvarTcDaiduongTluy2; }
        }
        public Double TcDaiduongTluy3
        {
            set { mvarTcDaiduongTluy3 = value; }
            get { return mvarTcDaiduongTluy3; }
        }
        public Double TcDaiduongTluy4
        {
            set { mvarTcDaiduongTluy4 = value; }
            get { return mvarTcDaiduongTluy4; }
        }
        public long TcId_Duongdo
        {
            set { mvarTcId_Duongdo = value; }
            get { return mvarTcId_Duongdo; }
        }
        public Boolean Cotai
        {
            set { mvarCotai = value; }
            get { return mvarCotai; }
        }
        public int Congtron
        {
            set { mvarCongtron = value; }
            get { return mvarCongtron; }
        }
        public Double KCachDay
        {
            set { mvarKCachDay = value; }
            get { return mvarKCachDay; }
        }
        public Double Soday
        {
            set { mvarSoday = value; }
            get { return mvarSoday; }
        }
        public Double Dayong
        {
            set { mvarDayong = value; }
            get { return mvarDayong; }
        }
        public Double Dayban
        {
            set { mvarDayban = value; }
            get
            {
                if (Congtron==1)
                {
                    return mvarDayong;
                }
                else
                {
                    return mvarDayban;
                }
            }
        }
        public Double Caocong
        {
            set { mvarCaocong = value; }
            get
            {
                if (Congtron == 1)
                {
                    return mvarDuongkinh * HsKc;
                }
                else
                {
                    return mvarCaocong * HsKc;
                }
            }
        }
        public Double Duongkinh
        {
            set { mvarDuongkinh = value * HsKc; }
            get { return mvarDuongkinh; }
        }
        public Double Dn
        {
            get { return Duongkinh + 2 * Dayong; }
        }
        public Double Rn
        {
            get { return 0.5 * Dn; }
        }
        public Double Hn
        {
            get
            {
                if (Congtron == 1)
                {
                    return Duongkinh + 2 * Dayong;
                }
                else
                {
                    return Caocong + 2 * Dayban;
                }
            }
        }
        public int Traiphai
        {
            set { mvarTraiphai = value; }
            get { return mvarTraiphai; }
        }
        public Double Tana
        {
            set { mvarTana = value; }
            get { return mvarTana; }
        }
        public Double Day
        {
            set { mvarDay = value; }
            get
            {
                if (mvarKtVuongGoc)
                {
                    return mvarDay / Math.Sin(GocXien);
                }
                else
                {
                    return mvarDay;
                }
            }
        }
        public Double DayMSau
        {
            set { mvarDayMSau = value; }
            get { return mvarDayMSau * HsKc; }
        }
        public Double DayMTr
        {
            set { mvarDayMTr = value; }
            get { return mvarDayMTr; }
        }
        public Double MrongB
        {
            set { mvarMrongB = value; }
            get { return mvarMrongB; }
        }
        public Double Mrongb4
        {
            set { mvarMrongb4 = value; }
            get { return mvarMrongb4; }
        }
        public Double MrongS
        {
            set { mvarMrongS = value; }
            get
            {
                if (!isRongMongD)
                {


                    if (mvarKtVuongGoc)
                    {
                        return mvarMrongS / Math.Sin(GocXien);
                    }
                    else
                    {
                        return mvarMrongS;
                    }
                }
                else
                {
                    return mvarRongMongD - mvarMrongT - Day - Lung;
                }
            }
        }
        public Double Mrongtuong
        {
            set { mvarMrongtuong = value; }
            get { return mvarMrongtuong; }
        }
        public Double MrongT
        {
            set { mvarMrongT = value; }
            get
            {
                if (KTVuongGoc)
                {
                    return mvarMrongT / Math.Sin(GocXien);
                }
                else
                {
                    return mvarMrongT;
                }
            }
        }
        public Double doc
        {
            set { mvarDoc = value; }
            get { return mvarDoc; }
        }
        public Double Cao
        {
            set { mvarCao = value; }
            get { return mvarCao * HsKc; }
        }
        public Double CaoH1Tc
        {
            set { mvarCaoH1Tc = value; }
            get { return mvarCaoH1Tc; }
        }
        public Double Goca1
        {
            set { mvarGoca1 = value; }
            get { return mvarGoca1 / 180 * Pi; }
        }
        public Double Goca2
        {
            set { mvarGoca2 = value; }
            get { return mvarGoca2 / 180 * Pi; }
        }
        public Double DayTc
        {
            set { mvarDayTc = value; }
            get { return mvarDayTc; }
        }
        public Double DayTcT
        {
            get
            {
                if (mvarKtVuongGoc)
                {
                    
                    if (Traiphai == -1)
                    {
                        return mvarDayTc / Math.Cos(Goca1 + GocXien - Pi / 2) * Math.Sin(GocXien);
                    }
                    else
                    {
                        return mvarDayTc / Math.Cos(Goca1 - GocXien + Pi / 2) * Math.Sin(GocXien);
                    }
                }
                else
                {
                    return mvarDayTc;
                }
            }
        }
        public Double DayTcD
        {
            get
            {
                if (mvarKtVuongGoc)
                {
                    if (Traiphai == -1)
                    {
                        return mvarDayTc / Math.Cos(Goca2 - GocXien + Pi / 2) * Math.Sin(GocXien);
                    }
                    else
                    {
                        return mvarDayTc / Math.Cos(Goca2 + GocXien - Pi / 2) * Math.Sin(GocXien);
                    }
                }
                else
                {
                    return mvarDayTc;
                }
            }
        }

        public Double Lopdem
        {
            set { mvarLopdem = value; }
            get { return mvarLopdem; }
        }
        public Double TlB
        {
            set { mvarTlB = value; }
            get { return mvarTlB; }
        }
        public String Tl
        {
            set { mvarTl = value; }
            get { return mvarTl; }
        }
        public int TlT
        {
            set { mvarTlT = value; }
            get { return mvarTlT; }
        }
        public Boolean KTVuongGoc
        {
            set { mvarKtVuongGoc = value; }
            get { return mvarKtVuongGoc; }
        }
        public String VlTaluy
        {
            set { mvarVlTaluy = value; }
            get { return mvarVlTaluy; }
        }
        public String VlTd
        {
            set { mvarVlTd = value; }
            get { return mvarVlTd; }
        }

        //'Phan mo rong tuong dau do vuot doc
        public Double Lung
        {
            get { return Cao / doc; }
        }
        public Double RongBen
        {
            get { return CaoH1Tc / doc; }
        }
        //'Chieu rong dinh tuong dau theo phuong ngang
        public Double TongRong
        {
            get { return (Duongkinh + 2 * Dayong) * Soday + KCachDay * (Soday - 1) - 2 * Dayong + 2 * Mrongb4; }
        }
        public Double DeltaRong
        {
            get { return (Duongkinh + 2 * Dayong) * (Soday - 1) / 2 + KCachDay * (Soday - 1) / 2; }
        }
        public Double RongDinh
        {
            get { return TongRong + DayTcT + DayTcD; }
        }
        //'Chieu rong chan tuong dau theo phuong ngang
        public Double RongChan
        {
            get { return RongDinh + 2 * RongBen; }
        }
        //'Chieu rong mong tuong dau theo phuong ngang
        public Double RongMongN
        {
            get { return RongChan + 2 * MrongB; }
        }
        //'Chieu rong mong tuong dau theo phuong doc
        public Double RongMongD
        {
            set { mvarRongMongD = value; }
            get
            {
                if (isRongMongD)
                {
                    return mvarRongMongD;
                }
                else
                {
                    return MrongT + MrongS + Day + Lung;
                }
            }
        }
        public Double Cosa
        {
            get { return Math.Sqrt(1 / (1 + Tana * Tana)); }
        }
        public Double Sina
        {
            get { return Math.Sqrt(1 - Cosa * Cosa); }
        }
        public Double Sind
        {
            get { return Math.Sqrt(1 - Cosd * Cosd); }
        }
        public Double Cosd
        {
            get { return Math.Sqrt(1 / (1 + Docdoc * Docdoc)); }
        }
        public int TraiphaiThan
        {
            get
            {
                if (Docdoc >= 0)
                {
                    return 1;
                }
                else return 0;
            }
        }
        public Double Chan
        {
            get { return Math.Round(Day + (Cao - CaoH1Tc) / doc, 2); }
        }
        public Double Chan1
        {
            get { return Math.Round(Day + Lung, 2); }
        }
        public Double Chan2
        {
            get { return Math.Round(Day + (Cao - (Caocong + Dayban)) / doc, 2); }
        }
        Double Tinhcu(Double a)
        {
            return a * 10 / Com.HsTl(Double.Parse(Tl), 1 - TlT);
        }
        public Double TlDim
        {
            get { return Com.HsTl(Double.Parse(Tl), TlT); }
        }
        String HatchName(String Vl)
        {
            switch (Vl.Substring(0, 3))
            {
                case "BTM": return "ansi31";
 
                case "DHX": return "Honey";
    
                default: return "Gravel";
            }
        }
        String MaterialName(String Vl)
        {
            switch (Vl)
            {
                case "BTM100":
                    return "Bê tông M100";
               
                case "BTM150":
                    return "Bê tông M150";
                
                case "BTM200":
                    return "Bê tông M200";
                 
                case "BTM250":
                    return "Bê tông M250";
                
                case "BTM300":
                    return "Bê tông M300";
                 
                case "DHMM75":
                    return  "Đá hộc miết mạch M75";
                
                case "DDD":
                    return  "Đá dăm đệm";
               
                case "DSD":
                    return  "Dăm sạn đệm";
               
                case "CPDD":
                    return  "Cấp phối đá dăm";
            
                default:
                    return  "Đá hộc xây vữa M100";
            }
        }
        ////////--------THKL-------////////
        

        Double Diengiai(Double giatri, int phanthapphan = 2)
        {
            //'Ham dung de dien giai cach tinh toan khoi luong
            return Math.Round(giatri * 0.001 * Com.HsTl(Double.Parse(Tl), 1 - TlT), phanthapphan);
        }
        Double HsKichthuoc()
        {
            return 0.001 * Com.HsTl(Double.Parse(Tl), 1 - TlT);
        }
        //'Tuong dau
        public Double Vtd()
        {
            Double mVtd;
            mVtd = (Diengiai(RongDinh) * Diengiai(Day) + Diengiai(RongChan) * Diengiai(Day + Lung)) / 2 * Diengiai(Cao);
            if (Congtron == 1 )
            {
                mVtd = mVtd - Soday * 3.14 * Diengiai(Duongkinh + 2 * Dayong) * Diengiai(Duongkinh + 2 * Dayong) / 4 * Diengiai((Chan2 + Chan1) / 2);
            }
            else
            {
                mVtd = mVtd - Soday * Diengiai(Duongkinh + 2 * Dayong) * Diengiai(Caocong + 2 * Dayban) * Diengiai((Chan2 + Chan1) / 2);
            }
            return Math.Round(mVtd, 2);
        }
        public String VtdDd()
        {
            String mVtdDd;
            mVtdDd = "(" + Diengiai(RongDinh) + "*" + Diengiai(Day) + "+" + Diengiai(RongChan) + "*" + Diengiai(Day + Lung) + ")/2*" + Diengiai(Cao);
            if (Congtron==1)
            {
                mVtdDd = mVtdDd + "-" + Soday + "*3.14*" + Diengiai(Duongkinh + 2 * Dayong) + "^2/4*" + Diengiai((Chan2 + Chan1) / 2);
            }
            else
            {
                mVtdDd = mVtdDd + "-" + Soday + "*" + Diengiai(Duongkinh + 2 * Dayong) + "*" + Diengiai(Caocong + 2 * Dayban) + "*" + Diengiai((Chan2 + Chan1) / 2);
            }
            return mVtdDd;
        }
        public Double VMtd()
        {
            Double mVMtd;
            mVMtd = 0.5 * Diengiai(DayMTr + DayMSau) * Diengiai(RongMongD) * Diengiai(RongMongN);
            return Math.Round(mVMtd, 2);
        }
        public String VMtdDd
        {
            get { return "0.5*" + Diengiai(DayMTr + DayMSau) + "*" + Diengiai(RongMongD) + "*" + Diengiai(RongMongN); }
        }
        public Double VkTd()
        {
            Double mVkTd;
            mVkTd = 2 * (Diengiai(Day) + Diengiai(Day + Lung)) * Diengiai(Math.Sqrt(Cao * Cao + Lung * Lung)) / 2;
            mVkTd = mVkTd + 2 * (Diengiai(RongDinh / Math.Sin(GocXien)) + Diengiai(RongChan / Math.Sin(GocXien))) * Diengiai(Math.Sqrt(Cao * Cao + Lung * Lung)) / 2;
            if (Congtron == 1)
            {
                mVkTd = mVkTd - 2 * Soday * 3.14 * Math.Pow((Diengiai(Duongkinh + 2 * Dayong)), 2) / 4;
            }
            else
            {
                mVkTd = mVkTd - 2 * Soday * Diengiai(Duongkinh + 2 * Dayong) * Diengiai(Caocong + 2 * Dayban);
            }
            if (VlTd.Substring(0, 2) =="BT" )
            {
                return Math.Round(mVkTd, 2);
            }
            return 0;
        }
        public String VktdDd()
        {
            String mVktdDd;
            mVktdDd = "2*(" + Diengiai(Day) + "+" + Diengiai(Day + Lung) + ")*" + Diengiai(Math.Sqrt(Cao * Cao + Lung * Lung)) + "/ 2";
            mVktdDd = mVktdDd + "+2*(" + Diengiai(RongDinh / Math.Sin(GocXien)) + "+" + Diengiai(RongChan / Math.Sin(GocXien)) + ")*" + Diengiai(Math.Sqrt(Cao * Cao + Lung * Lung)) + "/ 2";
            if (Congtron == 1)
            {
                mVktdDd = mVktdDd + "-2*" + Soday + "*3.14*" + (Diengiai(Duongkinh + 2 * Dayong)) + "^2/4";
            }
            else
            {
                mVktdDd = mVktdDd + "-2*" + Soday + "*" + Diengiai(Duongkinh + 2 * Dayong) + "*" + Diengiai(Caocong + 2 * Dayban);
            }
            return mVktdDd;
        }
        public Double VkMtd()
        {
            Double mVkMtd;
            mVkMtd = 2 * (Diengiai(RongMongD) + Diengiai(RongMongN / Math.Sin(GocXien))) * 0.5 * Diengiai(DayMTr + DayMSau);
            if (VlTd.Substring(0, 2) == "BT")
            {
                return Math.Round(mVkMtd, 2);
            }
            return 0;
        }
        public String VkMtdDd
        {
            get
            {
                return "2*(" + Diengiai(RongMongD) + "+" + Diengiai(RongMongN / Math.Sin(GocXien)) + ")*" + 0.5 * Diengiai(DayMTr + DayMSau);
            }
        }
        public Double Tovua()
        {
            Double mTovua;
            mTovua = Diengiai(RongDinh) * Diengiai(Cao - CaoH1Tc) + Diengiai(RongDinh - 2 * DayTc) * Diengiai(CaoH1Tc) + Diengiai(RongDinh) * Diengiai(Day);
            if (VlTd.Substring(0, 3)=="DHX")
            {
                return Math.Round(mTovua, 2);
            }
            return 0;
        }
        public string TovuaDd
        {
            get { return Diengiai(RongDinh) + "*" + Diengiai(Cao - CaoH1Tc) + "+" + Diengiai(RongDinh - 2 * DayTc) + "*" + Diengiai(CaoH1Tc) + "+" + Diengiai(RongDinh) + "*" + Diengiai(Day); }
        }
        // 'Lop dem
        public Double VLopdem()
        {
            Double mVLopdem;
            mVLopdem = Diengiai(RongMongN) * Diengiai(RongMongD) * Diengiai(Lopdem);
            if (SLopdem > 0 )
            {
                mVLopdem = mVLopdem + Diengiai(Diengiai(SLopdem)) * Diengiai(RongMongN);
            }
            return Math.Round(mVLopdem, 2);
        }
        public String VLopdemDd()
        {
            String mVLopdemDd = Diengiai(RongMongN) + "*" + Diengiai(RongMongD) + "*" + Diengiai(Lopdem);
            if (SLopdem > 0)
            {
                return mVLopdemDd + "+" + Diengiai(Diengiai(SLopdem)) + "*" + Diengiai(RongMongN);
            }
            return null;
        }
        // 'Dao dat dap dat
        public Double Daihodao
        {
            get { return Diengiai(RongMongD); }
        }
        public Double Ronghodao
        {
            get { return Diengiai(RongMongN) + 1; }
        }
        public Double Caohodao
        {
            get { return Diengiai((DayMTr + DayMSau) / 2); }
        }
        public Double VDaodat()
        {
            Double mVDaodat;
            mVDaodat = (Daihodao * Ronghodao + (Daihodao + Caohodao) * (Ronghodao + Caohodao)) / 2 * Caohodao;
            if ((Tdden is Array))
            {
                return Math.Round(mVDaodat, 2);
            }
            return 0;
        }
        public String VDaodatDd
        {
            get { return "(" + Daihodao + "*" + Ronghodao + "+" + (Daihodao + Caohodao) + "*" + (Ronghodao + Caohodao) + ")/2*" + Caohodao; }
        }

        //'Op mai taluy
        public Double VTaluy()
        {
            Double mVTaluy = new double() ;
            if (DaitaluyL > 0 )
            {
                mVTaluy = (Diengiai(RongtaluyB1) + Diengiai(RongtaluyB2)) / 2 * Diengiai(DaitaluyL) * Diengiai(Daytaluy);
                if (RongVaitaluy > 0)
                {
                    mVTaluy = mVTaluy + Diengiai(RongtaluyB1) * Diengiai(RongVaitaluy) * Diengiai(Daytaluy);
                }
                mVTaluy = mVTaluy - (Diengiai(RongDinh) + Diengiai(RongtaluyTc)) / 2 * Diengiai(DaitaluyTc) * Diengiai(Daytaluy);
            }
            return Math.Round(mVTaluy, 2);

        }
        public String VTaluyDd()
        {
            String mVTaluyDd="";
            if (DaitaluyL > 0 )
            {
                mVTaluyDd = "(" + Diengiai(RongtaluyB1) + "+" + Diengiai(RongtaluyB2) + ")/2* " + Diengiai(DaitaluyL) + "*" + Diengiai(Daytaluy);
                if (RongVaitaluy > 0 )
                {
                    mVTaluyDd = mVTaluyDd + "+" + Diengiai(RongtaluyB1) + "*" + Diengiai(RongVaitaluy) + "*" + Diengiai(Daytaluy);
                }
                mVTaluyDd = mVTaluyDd + "-(" + Diengiai(RongDinh) + "+" + Diengiai(RongtaluyTc) + ")/2*" + Diengiai(DaitaluyTc) + "*" + Diengiai(Daytaluy);
            }
            return mVTaluyDd;
        }
    }
}
